<template>
	<view>
		<view class="page-nav" style="background-color: #fff;" :style="'height:' +StatusBar+ 'px'"></view>
		<view class="search-box">
			<input class="uni-input" placeholder="清输代码/名称/简称" />
			<view class="search-but">
				搜索
			</view>
		</view>
		<view class="popular">
			<view class="popular-title">
				<view class="popular-icon">
					<image src="@/static/home/large.png" class="img-full"></image>
				</view>
				<view class="popular-text">
					热门合约
				</view>
			</view>
			<view class="decoration"></view>
			<view class="popular-items">
				<view class="popular-item" v-for="(item, i) in list" :key="i">
					<view class="popular-item-left"></view>
					<view class="popular-item-right">
						<view class="popular-item-title">
							{{item.name }}
						</view>
						<view class="popular-item-text">
							{{item.code}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			};
		},
		onLoad(e) {
			this.getContract()
		},
		methods: {
			getContract() {
				this.$request({
					url: this.$api.contract,
					method: 'get',
					data: {
						pageSize: '8',
						pageNum: 1,
					},
					successCb: (res) => {
						uni.hideLoading();
						// console.log('请求成功', res)
						this.list = res.rows.map(item => {
							return {
								...item,
								isSelect: false,
								isRise: (item.ratio.indexOf('-') == -1)
							}
						})
					},
					failCb(e) {
						// uni.hideLoading();
						console.log(e);
						uni.showToast({
							title: e.data.msg||'服务器异常',
							icon: "none",
							duration: 2000,
						});
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	page {
		
	}
	.search-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 702rpx;
		height: 72rpx;
		background: #F4F5F7;
		border-radius: 36rpx;
		overflow: hidden;
		margin: 24rpx auto;
		.uni-input {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: rgba(0,0,0,1);
			padding-left: 32rpx;
		}
		.search-but {
			width: 104rpx;
			height: 72rpx;
			background: #EE5953;
			border-radius: 36rpx;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 72rpx;
			text-align: center;
		}
	}
	
	.popular {
		width: 702rpx;
		background: linear-gradient(180deg, rgba(238,89,83,0.04) 0%, rgba(255,255,255,0) 100%);
		border-radius: 16rpx;
		border: 2rpx solid rgba(238,89,83,0.04);
		margin: 24rpx auto;
		padding: 32rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		.popular-title {
			display: flex;
			align-items: center;
			.popular-icon {
				width: 28rpx;
				height: 32rpx;
				margin-right: 18rpx;
			}
			.popular-text {
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #000000;
				line-height: 46rpx;
			}
		}
		.decoration {
			width: 60rpx;
			height: 10rpx;
			background: linear-gradient(90deg, #FF3B30 0%, rgba(255,59,48,0) 100%);
			margin-top: 16rpx;
			flex: none;
		}
		.popular-items {
			flex: 1;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: space-between;
			.popular-item {
				width: 50%;
				display: flex;
				margin-top: 24rpx;
				.popular-item-left {
					width: 12rpx;
					height: 12rpx;
					background: #EE5953;
					border-radius: 40%;
					margin-top: 14rpx;
				}
				.popular-item-right {
					margin-left: 16rpx;
					.popular-item-title {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: rgba(0,0,0,0.8);
					}
					.popular-item-text {
						font-size: 20rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: rgba(0,0,0,0.4);
					}
				}
			}
		}
	}

</style>
